<%@ page import="les.Integrante" %>
<html>
    <head>
    	<resource:autoComplete skin="default" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'encontro.label', default: 'Encontro')}" />
        <title>Enviar Mala Direta</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Inicio</a></span>
        </div>
        <div class="body">
            <h1>Integrantes da Mala Direta</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${usuarioInstance}">
            <div class="errors">
                <g:renderErrors bean="${usuarioInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                        	
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="equipes">Nome do Integrante</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: usuarioInstance, field: 'malaDireta', 'errors')}">
                                    <richui:autoComplete name="integrante" action="${createLinkTo('dir': 'send/procurarIntegrante')}" />
                                </td>
                            </tr>
                        
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit id="adicionar" name="adicionar" value="Adicionar" action="adicionarIntegrante"/></span>
                    <span class="button"><g:actionSubmit id="criarMala" name="criarMala" value="criar mala direta" action="criarMala"/></span>
                </div>
            </g:form>
		
			<h1>Adicionados</h1>
		
		<table>
  		<tr>
  		<th>Email do Integrante</th>
  		<th>Remover email</th>
  		</tr>
  		<g:each in="${usuarioInstance?.id}" var="idUsuario">
	  		<g:each in="${usuarioInstance?.malaDireta}" status="i" var="email">
	    	<tr>
	    	<td>${email}</td>
	    	<td>
	    	<g:link id="removerEmail" action="removerEmail" params="[email:email]">Excluir</g:link></td>
	    	</tr>
	    	</g:each>
		</g:each>
  		
		</table>
		
        </div>
    </body>
</html>
